﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Messaging;
using System.Text;
using System.Threading.Tasks;

namespace MessageQueues.MSMQ
{
    /// <summary>
    /// MSMQ队列操作的属性设置
    /// </summary>
    public class MessageQueueSettings
    {
        /// <summary>
        /// 专用队列的基本路径
        /// </summary>
        private string basePath = "private$";

        /// <summary>
        /// 队列的ID
        /// </summary>
        public Guid MessageQueueId { get; set; }

        /// <summary>
        /// 队列的标签
        /// </summary>
        public string MessageQueueLabel { get; set; } = "由程序创建的默认消息队列";

        /// <summary>
        /// 访问队列的路径，默认是本机，记做“.”
        /// </summary>
        public string RemotePath { get; set; } = ".";

        /// <summary>
        /// 队列的路径
        /// </summary>
        public string MessageQueuePath => $"{RemotePath}\\{basePath}\\{MessageQueueName}";

        /// <summary>
        /// 队列名称：默认是MSMQDefault
        /// </summary>
        public string MessageQueueName { get; set; } = Config.ConfigSource.DefaultMSMQName;

        /// <summary>
        /// 消息队列类型
        /// </summary>
        public QueueType MessageQueueType { get; set; } = QueueType.PrivateQueue;

        /// <summary>
        /// 获取或设置队列日志的大小
        /// </summary>
        public long MaximumJournalSize { get; set; } = uint.MaxValue;

        /// <summary>
        /// 是否启用日志
        /// </summary>
        public bool UseJournalQueue { get; set; } = true;

        /// <summary>
        /// 获取或设置队列的大小
        /// </summary>
        public long MaximumQueueSize { get; set; } = uint.MaxValue;

        /// <summary>
        /// 是否启用队列事务
        /// </summary>
        public bool IsUseTransaction { get; set; } = true;

        /// <summary>
        /// 队列的访问方式
        /// </summary>
        public QueueAccessMode AccessMode { get; set; } = QueueAccessMode.SendAndReceive;

        /// <summary>
        /// 设置/获取是否经过身份验证
        /// </summary>
        public bool Authenticate { get; set; } = false;

        /// <summary>
        /// 获取或设置基优先级，“消息队列”使用该基优先级在网络上传送公共队列的消息。
        /// </summary>
        public short BasePriority { get; set; } = 0;
    }
}
